package com.aosd.project.aonotepad.domain;

import java.util.ArrayList;
import java.util.List;

import com.aosd.project.aonotepad.domain.category.Category;
import com.aosd.project.aonotepad.domain.file.File;
import com.aosd.project.aonotepad.domain.template.NoteTemplate;

public class Note 
{
	private String content;
	private File file;
	private Category category;
	private List<Link> links;
	
	private Note()
	{
		links = new ArrayList<Link>();
	}
	
	// new note
	public Note(NoteTemplate template, String path)
	{
		this();
		content = template.createContent();
		file = template.createFile(path);
		category = template.createCategory();
	}
	
	public void save()
	{
		file.save(this);
	}
	
	// load from file
	public Note(File f)
	{
		this();
		this.file = f;
		
		// load the contents
		Note noteFromFile = f.open();
		content = noteFromFile.getContent();
		category = noteFromFile.getCategory();
		links = noteFromFile.getLinks();
	}
	
	public Category getCategory()
	{
		return category;
	}
	
	public String getContent()
	{
		return content;
	}
	
	public List<Link> getLinks()
	{
		return links;
	}
}
